<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE HTML>
<html>
<head>
<title>后台登录 - AMS v1.0</title>
<meta charset="utf-8">
<meta name="keywords" content="AMS">
<meta name="description" content="AMS">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="${ctx }/resources/favicon.ico" >
<LINK rel="Shortcut Icon" href="${ctx }/resources/favicon.ico" />
<!--[if lt IE 9]>
<script type="text/javascript" src="${ctx }/resources/lib/html5.js"></script>
<script type="text/javascript" src="${ctx }/resources/lib/respond.min.js"></script>
<script type="text/javascript" src="${ctx }/resources/lib/PIE_IE678.js"></script>
<![endif]-->
<link href="${ctx }/resources/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="${ctx }/resources/css/H-ui.login.css" rel="stylesheet" type="text/css" />
<link href="${ctx }/resources/css/style.css" rel="stylesheet" type="text/css" />
<link href="${ctx }/resources/lib/Hui-iconfont/1.0.7/iconfont.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
</head>
<body>
<input id="accountId" type="hidden" value="<c:if test="${not empty sessionScope.accountSessionId}">${sessionScope.accountSessionId }</c:if>"/>
<div class="header"></div>
<div class="loginWraper">
  <div id="" class="loginBox">
    <form id="loginform" name="loginform" class="form form-horizontal" action="${ctx }/login" method="post">
      <div class="row cl">
        <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
        <div class="formControls col-xs-8">
          <input id="accountName" name="accountName" type="text" placeholder="账户" class="input-text size-L">
        </div>
      </div>
      <div class="row cl">
        <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60e;</i></label>
        <div class="formControls col-xs-8">
          <input id="password" name="password" type="password" placeholder="密码" class="input-text size-L">
        </div>
      </div>
      <div class="row cl">
        <div class="formControls col-xs-8 col-xs-offset-3">
          <input id="captcha" name="captcha" class="input-text size-L" type="text" placeholder="验证码" onblur="if(this.value==''){this.value='验证码:'}" onclick="if(this.value=='验证码:'){this.value='';}" value="验证码:" style="width:150px;">
          <img id="kaptchaImage" src="${ctx }/captcha" title="看不清，点击更换"> 
        </div>
      </div>
      <div class="row cl">
        <div class="formControls col-xs-8 col-xs-offset-3">
          <label for="online">
            <input type="checkbox" name="rememberMe" id="rememberMe" value="true">
            使我保持登录状态</label>
        </div>
      </div>
      <div class="row cl">
        <div class="formControls col-xs-8 col-xs-offset-3">
          <input onclick="login();" type="button" class="btn btn-success radius size-L" value="&nbsp;登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;">
          <input name="" type="reset" class="btn btn-default radius size-L" value="&nbsp;取&nbsp;&nbsp;&nbsp;&nbsp;消&nbsp;">
        </div>
      </div>
    </form>
  </div>
</div>
<div class="footer">Copyright 你的公司名称 </div>
<script type="text/javascript" src="${ctx }/resources/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="${ctx }/resources/js/H-ui.js"></script> 
<script type="text/javascript">
var sys = sys || {};
sys.rootPath = "${ctx}";
$(function() {
	//错误提示信息
	if ("${error}" != "") {
    	alert('${error}');
	}
	
	//页面进行跳转到login
	if (window.location.href.indexOf("/login") == -1) {
	    if($("#userId").val() == null || $("#userId").val() == "")
	    {
	        top.location.href = "login";
	    }else
	    {
	        top.location.href = "index";
	    }
	}
	
	//刷新验证码
    $('#kaptchaImage').click(function() {//生成验证码
        $(this).hide().attr('src', 'captcha?' + new Date().getTime()).fadeIn();
    });
	
  	//注册回车键事件
    document.onkeypress = function(e){
    var ev = document.all ? window.event : e;
        if(ev.keyCode==13) {
            login();
        }
    };
});

//登录
function login() {
    if($("#accountName").val() == "") {
        alert('请输入账户邮箱', {icon : 5,shift : 6,time : 0});
        $("#accountName").focus();
        return false;
    } else {
        var reg = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
        if(!reg.test($("#accountName").val())) {
            alert('请输入正确的邮箱', {icon : 5,shift : 6,time : 0});
            $("#accountName").focus();
            return false;
        }
    }
    if($("#password").val() == "") {
        alert('请输入密码', {icon : 5,shift : 6,time : 0});
        $("#password").focus();
        return false;
    }
    if($("#captcha").val() == "") {
        $("#captcha").focus();
        alert('请输入验证码', {icon : 5,shift : 6,time : 0});
        return false;
    }
    if($("#rememberMeCheckBox").is(':checked')) {
        $("#rememberMe").val(true);
    }
    $("#loginform").submit();
}
</script>
</body>
</html>
